package com.rayo.accesscontrollercopy.model.db.bean;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.litesuits.orm.db.annotation.Column;
import com.litesuits.orm.db.annotation.Table;
import com.rayo.accesscontrollercopy.config.NetworkConfig;

import java.util.Date;
import java.util.List;

/**
 * Created by yanghaojie on 16/7/27.
 */
@Table("cardtime_table")
public class CardTimezoneData extends BaseModel {
    public static final String USERID = "userid";
    public static final String SERIAL_ID = "serial";
    public static final String FTIME = "fromtime";
    public static final String TTIME = "totime";

    @Column(USERID)
    private int userid;
    @Column(SERIAL_ID)
    private int serial;
    @Column(FTIME)
    @JSONField(format = NetworkConfig.JSON_TIME)
    private Date from;
    @Column(TTIME)
    @JSONField(format = NetworkConfig.JSON_TIME)
    private Date to;

    private int sun;

    private int mon;

    private int tue;

    private int wed;

    private int thu;

    private int fri;

    private int sat;

    public CardTimezoneData() {
        this.userid = 0;
        this.serial = 0;
        this.from = new Date();
        this.to = new Date();
        this.sun = 0;
        this.mon = 0;
        this.tue = 0;
        this.wed = 0;
        this.thu = 0;
        this.fri = 0;
        this.sat = 0;
        this.editime = new Date();
    }

    public void updateData(CardTimezoneData item) {
        this.setFrom(item.getFrom());
        this.setTo(item.getTo());
        this.setSun(item.getSun());
        this.setMon(item.getMon());
        this.setTue(item.getTue());
        this.setWed(item.getWed());
        this.setThu(item.getThu());
        this.setFri(item.getFri());
        this.setSat(item.getSat());
    }

    public int getUserid() {
        return userid;
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }

    public int getSerial() {
        return serial;
    }

    public void setSerial(int serial) {
        this.serial = serial;
    }

    public Date getFrom() {
        return from;
    }

    public void setFrom(Date from) {
        this.from = from;
    }

    public Date getTo() {
        return to;
    }

    public void setTo(Date to) {
        this.to = to;
    }

    public int getSun() {
        return sun;
    }

    public void setSun(int sun) {
        this.sun = sun;
    }

    public int getMon() {
        return mon;
    }

    public void setMon(int mon) {
        this.mon = mon;
    }

    public int getTue() {
        return tue;
    }

    public void setTue(int tue) {
        this.tue = tue;
    }

    public int getWed() {
        return wed;
    }

    public void setWed(int wed) {
        this.wed = wed;
    }

    public int getThu() {
        return thu;
    }

    public void setThu(int thu) {
        this.thu = thu;
    }

    public int getFri() {
        return fri;
    }

    public void setFri(int fri) {
        this.fri = fri;
    }

    public int getSat() {
        return sat;
    }

    public void setSat(int sat) {
        this.sat = sat;
    }

    public static List<CardTimezoneData> formJsonStr(String data) {
        List<CardTimezoneData> list;
        try {
            list = JSON.parseArray(data, CardTimezoneData.class);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return list;
    }
}
